﻿using Entity;
using Entity.UserPermissionss;
using Entity.UserRoles;
using EntityFrameWorkCore;
using FrameWorkCore;
using FrameWorkCore.CustomFilter;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Repository.Repository;

namespace WebApi6.Controllers
{
     
    [Authorize]
    [ApiController]
    [Route("api/[controller]/[action]")]
    public abstract class ControllerBases: ControllerBase
    {
        public IRepository<User, Guid, DefaultDbContext> UserRep { get; set; }

        public IRepository<Role, Guid, DefaultDbContext> RoleRep { get; set; }

        public IRepository<UserRole, Guid, DefaultDbContext> UserRoleRep { get; set; }



        protected async ValueTask<User> GetCurrentUserAsync()
            => await UserRep.GetAsync(Guid.Parse(base.User.Claims.First(x => x.Type == "SubjectId").Value));
            
    }
}
